home *** CD-ROM | disk | FTP | other *** search
/ Quick PC 62 / Quick PC 62.iso / I386 / IIS5_01.CAB / IIS_iiputls.asp < prev    next >
Encoding:
Text File  |  1999-07-09  |  8.5 KB  |  378 lines

  1. <%@ LANGUAGE = VBScript %>
  2. <% 'Option Explicit %>
  3. <!-- #include file="directives.inc" -->
  4.  
  5. <!--#include file="iiputls.str"-->
  6.  
  7. <%
  8. Const ADS_PROPERTY_CLEAR = 1
  9.  
  10.  
  11. On Error Resume Next 
  12.  
  13. Dim path, currentobj, SpecObject, lasterr, key, changed, clearPaths
  14.  
  15. lasterr=""
  16. changed = false
  17. path=Session("path")
  18. Set currentobj=GetObject(path)
  19. if Session("clearPathsOneTime") <> "" then 
  20.     clearPaths = Session("clearPathsOneTime")
  21. else
  22.     clearPaths = (Session("clearPaths") <> "")
  23. end if
  24.  
  25. SpecObject = ""
  26. SpecObject = GetObjectType(SpecObject, Session("SpecObj"),"Filters")
  27. SpecObject = GetObjectType(SpecObject, Session("SpecObj"),"Mime")
  28. SpecObject = GetObjectType(SpecObject, Session("SpecObj"),"IPSecurity")
  29. SpecObject = GetObjectType(SpecObject, Session("SpecObj"),"Operators")
  30.  
  31.  
  32. Select Case SpecObject
  33.     Case "Filters"
  34.         saveFilters        
  35.     Case "Mime"
  36.         saveMIMEs    
  37.     Case "IPSecurity"
  38.         saveIPSecurity
  39.     Case "Operators"
  40.         saveOperators
  41.     Case Else
  42.         saveGenericLists        
  43. End Select
  44.  
  45.  
  46. Function getObjectType(SpecObject,SpecObjString,ObjType)
  47.         
  48.     If InStr(SpecObjString,ObjType) > 0 then
  49.         getObjectType = ObjType
  50.     Else
  51.         getObjectType = SpecObject
  52.     End If
  53.  
  54. End Function
  55.  
  56. Sub killChildPaths(key, thisobj)
  57.  
  58.     dim aSetChildPaths, childpath, child
  59.     
  60.     if clearPaths then
  61.         aSetChildPaths = thisobj.GetDataPaths(key,IIS_DATA_INHERIT) 
  62.         For Each childpath in aSetChildPaths
  63.             childPath = cleanPath(childPath)
  64.             
  65.             Set child = GetObject(childpath)
  66.             if child.ADSPath <> thisobj.ADSPath then
  67.                 if (instr(LCase(child.ADSPath), "IIS://localhost/w3svc/info") > 0) OR (instr(LCase(child.ADSPath), "IIS://localhost/msftpsvc/info") > 0) then        
  68.                 else
  69.                     child.PutEx ADS_PROPERTY_CLEAR, key, ""
  70.                     child.SetInfo
  71.                 end if
  72.             end if
  73.         Next    
  74.     end if
  75.     Session("clearPathsOneTime") = ""
  76. End Sub
  77.  
  78. Function cleanPath(pathstr)
  79.     if Right(pathstr,1) = "/" then
  80.         pathstr = Mid(pathstr, 1,len(pathstr)-1)
  81.     end if
  82.     cleanPath = pathstr
  83. End Function
  84.  
  85. Sub saveGenericLists()
  86.  
  87. dim proparray, oldarray
  88.         proparray=Array()
  89.  
  90.         For Each key In Request.Form
  91.  
  92.             if (key="DELETED" or key="NEWITEM") then
  93.             else                
  94.                 proparray = setPropArray()                            
  95.                 oldarray=currentobj.Get(key)
  96.  
  97.                 Response.write "New Array" & "<BR>"
  98.                 printarray(proparray)
  99.                 Response.write "Old Array" & "<BR>"
  100.                 printarray(oldarray)                                                
  101.                 if chkUpdated(oldarray,proparray) then
  102.                     currentobj.Put key, (proparray)
  103.                     killChildPaths key, currentobj
  104.                 end if
  105.             end if
  106.         Next
  107.         currentobj.SetInfo
  108. End Sub
  109.  
  110. Sub saveOperators()
  111.     dim currentobj, secdes, dacl, Ace, NewAce, Trustee
  112.     dim proparray
  113.     
  114.     proparray=Array()
  115.     key = "Trustee"
  116.     Set currentobj = GetObject(path)
  117.     Set secdes = currentobj.Get("AdminACL")
  118.     Set dacl = secdes.DiscretionaryACL    
  119.  
  120.     proparray = setPropArray()            
  121.  
  122.     'First, clear down our control list...
  123.     currentobj.PutEx ADS_PROPERTY_CLEAR, "AdminACL", ""
  124.     currentobj.SetInfo
  125.     Set currentobj = GetObject(path)
  126.     Set secdes = currentobj.Get("AdminACL")
  127.     Set dacl = secdes.DiscretionaryACL    
  128.     
  129.     For Each Trustee in proparray
  130.         'Ignore the administrator trustees. These are special and will be set automatically by the object.
  131.         if Trustee <> L_BIADMINISTRATORS_TEXT and Trustee <> L_ADMINISTRATORS_TEXT then
  132.             ' Set up the ACEs
  133.             Set NewAce = CreateObject("AccessControlEntry")
  134.             NewAce.Trustee = Trustee        
  135.             NewAce.AccessMask = 11
  136.             dacl.AddAce NewAce                
  137.         end if
  138.     Next
  139.     secdes.DiscretionaryACL = (dacl)
  140.     currentobj.AdminACL = secdes
  141.     currentobj.SetInfo
  142.     killChildPaths "AdminACL", currentobj 
  143. End Sub
  144.  
  145. Sub saveIPSecurity()
  146.  
  147.     Dim sobj, specprops, dd
  148.     Dim proparray, oldarray
  149.         response.write currentobj.ADsPath
  150.         Set sobj=currentobj.Get(Session("SpecObj"))    
  151.         specprops=UCase(Session("SpecProps"))
  152.     
  153.         proparray=Array()
  154.     
  155.         For Each key In Request.Form
  156.             if (key="DELETED" or key="NEWITEM") then
  157.             else
  158.                 proparray = setPropArray()        
  159.                 Select Case UCase(key)
  160.                 Case "IPGRANT" 
  161.                         oldarray=sobj.IPGrant
  162.                 Case "IPDENY" 
  163.                         oldarray=sobj.IPDeny
  164.                 Case "DOMAINGRANT" 
  165.                         oldarray=sobj.DomainGrant
  166.                 Case "DOMAINDENY" 
  167.                         oldarray=sobj.DomainDeny
  168.                 End Select
  169.  
  170.                 if chkUpdated(oldarray,proparray) then
  171.                     Select Case UCase(key)
  172.                     Case "IPGRANT"  
  173.                         sobj.IPGrant=(proparray)
  174.                     Case "IPDENY" 
  175.                         sobj.IPDeny=(proparray)
  176.                     Case "DOMAINGRANT" 
  177.                         sobj.DomainGrant=(proparray)
  178.                     Case "DOMAINDENY" 
  179.                         sobj.DomainDeny=(proparray)
  180.                     End Select
  181.                 end if                            
  182.             end if
  183.         Next
  184.  
  185.         if Session("SpecObj")="IPSecurity" then
  186.             currentobj.IPSecurity=sobj
  187.         end if 
  188.         
  189.         currentobj.SetInfo
  190.         killChildPaths "IPSecurity", currentobj 
  191.  
  192. End Sub
  193.  
  194. Sub saveFilters()
  195.  
  196.     Dim filterspath, filterCol, loadOrder, formsize, filtername,fltrObj, fltr,i
  197.  
  198.         filterspath = path & "/Filters"
  199.     
  200.         if isObject(filterspath) then
  201.             Set filterCol = GetObject(filterspath)
  202.         else
  203.             Set filterCol=currentobj.Create("IIsFilters","Filters")
  204.         end if
  205.  
  206.                 
  207.         loadOrder = Request.Form("FilterName")
  208.         filterCol.FilterLoadOrder = (loadOrder)
  209.         filterCol.KeyType = "IIsFilters"    
  210.         filterCol.SetInfo
  211.  
  212.         formsize=Request.Form("FilterName").Count-1
  213.         For i=0 to formsize
  214.             
  215.             filtername = Request.Form("FilterName")(i+1)
  216.             Response.write filtername
  217.             if filtername <> "" then                
  218.                 if isObject(filterspath & "/" & filtername) then
  219.                     Set fltrObj = GetObject(filterspath & "/" & filtername)
  220.                 else
  221.                     Set fltrObj=filterCol.Create("IIsFilter",filtername)
  222.                 end if            
  223.                 fltrObj.FilterPath = (Request.Form("FilterPath")(i+1))
  224.                 fltrObj.SetInfo
  225.             end if
  226.         Next
  227.  
  228.         'now, make sure we haven't deleted or renamed any...
  229.         For Each fltr in filterCol
  230.             filtername = fltr.Name
  231.             Response.write filtername
  232.             if InStr(loadOrder,filtername) = 0 then                
  233.                 filterCol.Delete "IIsFilter", filtername
  234.             end if        
  235.         Next    
  236.         filterCol.SetInfo
  237.         
  238. End Sub
  239.  
  240. Sub saveMIMES()
  241.     
  242.     Dim MIMEpath, MimeMaps, formsize, i, Map
  243.     Dim aMimeMap
  244.  
  245.     if Session("vtype") = "comp" then
  246.         MIMEpath = path & "/MimeMap"
  247.     else
  248.         MIMEpath = path
  249.     end if     
  250.         
  251.  
  252.     if isObject(MIMEpath) then
  253.         Set MimeMaps = GetObject(MIMEpath)
  254.     else
  255.         Set MimeMaps=currentobj.Create("IIsMimeMap","MimeMap")
  256.         MimeMaps.KeyType = "IIsMimeMap"            
  257.         MimeMaps.SetInfo            
  258.     end if
  259.  
  260.     aMimeMap = MimeMaps.MimeMap
  261.     formsize=Request.Form("ext").Count-1    
  262.     ReDim aMimeMap(formsize)
  263.     i = 0
  264.     if (formsize = 0 and Request.Form("ext")(1) <> "") or formsize > 0 then
  265.         For i = 0 to formsize
  266.             Set Map = CreateObject("Mimemap")
  267.             Map.Extension=Request.Form("ext")(i+1) 
  268.             Map.MimeType=Request.Form("app")(i+1) 
  269.             Set aMimeMap(i) = Map
  270.         Next
  271.         MimeMaps.Mimemap = aMimeMap
  272.     else
  273.         MimeMaps.PutEx ADS_PROPERTY_CLEAR, "MimeMap", ""
  274.         MimeMaps.GetInfo
  275.     end if    
  276.     MimeMaps.SetInfo
  277.  
  278. End Sub
  279.  
  280. Function setPropArray()
  281.     
  282.     dim formsize,arraysize,i, j
  283.     dim proparray
  284.  
  285.     'key is global
  286.     formsize=Request.Form(key).Count-1
  287.     arraysize=0
  288.     for i=0 to formsize
  289.     if Request.Form(key)(i+1) <> "" then
  290.         arraysize=arraysize + 1
  291.     end if
  292.     Next
  293.  
  294.     if arraysize=0 then
  295.         ReDim proparray(0)        
  296.         if (Request.Form(key)(1) <> "") then
  297.             proparray(0)=Request.Form(key)(1)
  298.         else
  299.             proparray = Array()
  300.         end if
  301.     else
  302.         ReDim proparray(arraysize-1)    
  303.         j=0
  304.  
  305.         for i=0 to formsize
  306.             
  307.             if Request.Form(key)(i+1) <> "" then        
  308.                 proparray(j)=Request.Form(key)(i+1)
  309.                 j=j+1                
  310.             end if
  311.         Next
  312.     end if    
  313.     
  314.     setPropArray = proparray
  315.     
  316. End Function
  317.  
  318. Function chkUpdated(oldarray,proparray)
  319.  
  320.     dim proparraybound,arrayWasUpdated, i
  321.     
  322.     if IsArray(oldarray) then
  323.         proparraybound=UBound(proparray)
  324.         if UBound(oldarray) <> proparraybound then
  325.             arrayWasUpdated=true
  326.         else
  327.             for i=0 to proparraybound
  328.                 if oldarray(i) <> proparray(i) then                    
  329.                     arrayWasUpdated=true
  330.                 end if
  331.             Next
  332.         end if
  333.     else        
  334.         if proparraybound > 0 then
  335.             arrayWasUpdated=true
  336.         else
  337.             arrayWasUpdated=(proparray(0) <> oldarray)            
  338.         end if
  339.     end if
  340.     
  341.     'set our global changed var
  342.     changed = arrayWasUpdated
  343.     
  344.     chkUpdated = arrayWasUpdated
  345.     
  346. End Function
  347.  
  348. Function printarray(aprop)
  349.     Dim prop
  350.     for each prop in aprop
  351.         response.write prop & "<BR>"
  352.     next
  353. End Function 
  354.  
  355. Function isObject(path)
  356.     On Error Resume Next
  357.     Dim testObj
  358.     set testObj = GetObject(path)
  359.     isObject = (err = 0)
  360.     err = 0
  361. End Function
  362.  
  363. %>
  364.  
  365. <SCRIPT LANGUAGE="JavaScript">
  366.         parentdoc = parent.location.href;
  367.         if (parentdoc.indexOf("pop") != -1){
  368.             top.location.href="iipopcl.asp";
  369.         }
  370. </SCRIPT>
  371. <HTML>
  372. <BODY BGCOLOR="#000000" TEXT="#FFCC00" TOPMARGIN=0 LEFTMARGIN=0>
  373. </BODY>
  374. </HTML>
  375.  
  376.  
  377.  
  378.